#include "processBar.h" 
#include <string.h>
#include <unistd.h> 


#define  GREEN "\033[0;32;32m"

#define END "\033[m"




const char * label = "|/-\\";


char bar[NUM]={0};
//如何被调用

void processbar(int rate)
{


   int len = strlen(label);



  if(rate<0 || rate >100)
  {
  return;


  }


   printf(GREEN"[%-100s]"END"[%d%%][%c]\r",bar,rate,label[rate%len]);


    fflush(stdout);

    bar[rate++] = BODY;

    if(rate<TOP)
    {
    

        bar[rate] = RIGHT;



    }







}


void initbar()
{

  memset(bar,'\0',sizeof(bar));
  





}



























/*

const char * lable = "|/-\\";


void processbar(int speed)
{
 

  char bar[NUM];

  memset(bar,'\0',sizeof(bar));

  int cnt = 0;

  int len = strlen(lable);

  while(cnt <=100)
  {

  
    printf("[%-100s][%d%%][%c]\r",bar,cnt,lable[cnt%len]);//没有\n，就没有立即刷新。因为显示器模式是行刷新
     fflush(stdout);

    bar[cnt++] = BODY ;
   if(cnt<TOP)
   {

   bar[cnt] = RIGHT;
   }

  //  sleep(1);
  //
      usleep(speed);


  }

  // printf("hello processbar\n");
 

  printf("\n");


}
 

*/ 
